package cn.csq.array;

/**
 * @author <a href="mailto:csq02198031@alibaba-inc.com">chengshanqing</a>
 * @date 2025/8/19 15:52
 */
public class SelfDynamicArray<T> {

    //  存储
    private T[] data;

    private int size = 0;

    private static final int init_size = 10;

    public SelfDynamicArray() {
        this(init_size);
    }

    public SelfDynamicArray(int size) {
        this.data = (T[]) new Object[size];
    }

    // 增
    private void addLast(T t) {
        // 判断是否超过
        if (size == data.length) {
            //
            resize();
        }
        ;

    }

    private void resize() {
        T[] temp = (T[]) new Object[size * 2];
        // 移动元素
        for (int i = 0; i <= data.length - 1; i++) {
            temp[i] = data[i];
        }
        this.data = temp;
    }


}
